home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / phpf.bst < prev    next >
Lisp/Scheme  |  1992-07-19  |  61KB  |  1,878 lines

  1. % BibTeX styles for various physics journals (27-Feb-1990).
  2. % This file, physics.btx, is based on the file btxbst.doc.
  3.     % Please notify Charles Karney (Karney@Princeton.EDU)
  4.     % of any bugs, improvements, etc.
  5. % Run this file through cpp to get specific versions.  I have written
  6. % a version of cpp within Emacs.  To access it put
  7. %    (autoload 'cpp "tex$bibtex:cpp"        ; Use cpp for BibTeX styles
  8. %          "C preprocessor"
  9. %          t)
  10. % into your .emacs file.  Read in this file with
  11. %    emacs tex$bibtex:physics.btx
  12. % and run cpp with e.g.,
  13. %    M-x cpp <ret> aip <ret>
  14. % Save the resulting file to tex$latex:aip.bst.
  15. % To accomodate the variations we need (in addition to the definitions below)
  16. %    ATIT_SUPPRESS:    do not include the titles of journal articles
  17. %    NAME_INVERT:    put the initials last
  18. %    NAME_UPPER:    convert names to all caps.
  19. %    MONTH_SUPPRESS:    do not include months in journal articles
  20. %    PAREN_DATE:    dates go in parens in journal articles
  21. %    DATE_FIRST:    dates go before page numbers
  22. %    VOLUME_SPACE:    volume set off with space (not colon)
  23. %    NUM_SUPPRESS:    do not include numbers in journal articles
  24. %    BOLD_VOL:    volume numbers in bold face in journal articles
  25. %    BRACKET_NOTE:    notes in brackets
  26. %    PAGE_START_J:    include only starting page for journal articles
  27. %    PAGE_START_O:    include only starting page for other entries
  28. %    PAGE_ABBREV:    abbreviate page to p. and pages to pp.
  29. %    PHYSICS_JOUR:    include abbreviations for Physics journals
  30. %    COMMA_DELIMIT:    use comma (instead of period) to divide a citation
  31. %    NOTE_SUPPRESS:    suppress the note
  32. %    MAX_NAMES:    max number of authors before using et al (0 = infinity)
  33. %    MIN_NAMES:    number of authors to list with et al.
  34. %    EDIT_VAR:    use "edited by ..." instead of "..., editors"
  35. %    RMP_LABELS:    create RMP-style labels
  36. %    KEY_CITE:    use key as label
  37. %    NAMED_REFS:    use (Smith, 1988) style of citations
  38. %    CSC_NAMES:    names set in caps and small caps
  39. %    JOUR_DEEMPH:    don't emphasize journal name
  40. %    ETAL_EMPH:    emphasize et al.
  41. %    ALT_INCOLL    alternate ordering of fields in incollections
  42. % These are all boolean (0 or 1) except for MAX_NAMES and MIN_NAMES.
  43. % These need to satisfy 0 <= MIN_NAMES <= MAX_NAMES.
  44. % The rule here is that if all these are defined to be zero, we revert to
  45. % the standard styles.  For that reason we initialize them all to 0.
  46. % These are the original macros
  47.     % For Physics of Fluids, which now wants ALL the authors
  48.     %  (Same as AIP but infinite names, abbreviate pages, and
  49.     %  alternate incollection)
  50. % This is the start of btxbst.doc
  51. % BibTeX `plain' family
  52.     % version 0.99b for BibTeX versions 0.99a or later, LaTeX version 2.09.
  53.     % Copyright (C) 1985, all rights reserved.
  54.     % Copying of this file is authorized only if either
  55.     % (1) you make absolutely no changes to your copy, including name, or
  56.     % (2) if you do make changes, you name it something other than
  57.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  58.     % This restriction helps ensure that all standard styles are identical.
  59.     % The file btxbst.doc has the documentation for this style.
  60. % Please notify Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU) of any bugs in
  61. % these standard styles or in this documentation file.
  62. %
  63. % This is file btxbxt.doc; it helps document bibliography styles,
  64. % and is also a template file that you can use to make
  65. % several different style files, if you have access to a C preprocessor.
  66. % For example, the standard styles were made by doing something like
  67. %    cpp -P -DPLAIN btxbst.doc plain.txt
  68. %    cpp -P -DUNSRT btxbst.doc unsrt.txt
  69. %    cpp -P -DALPHA btxbst.doc alpha.txt
  70. %    cpp -P -DABBRV btxbst.doc abbrv.txt
  71. % and then renaming after removing unwanted comments and blank lines.
  72. % If you don't have access,
  73. % you can edit this file by hand to imitate the preprocessor,
  74. % with the following explanation of the C preprocessor constructs used here.
  75. %
  76. % The output of the preprocessor is the same as the input, except that certain
  77. % lines will be excluded (and some blank lines will be added).  The sequence
  78. %    #if VAR
  79. %        lines to be included when VAR is not zero
  80. %    #else
  81. %        lines to be included when VAR is zero
  82. %    #endif
  83. % (with the #-signs appearing in column 1) means that one set or the other of
  84. % the lines are to be included depending on the value of VAR.
  85. % The #else part is optional.  Comments can be added after #else and #endif.
  86. % Variables can be set by
  87. %    #define VAR value
  88. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  89. % to see if it has none.
  90. % Another #if form used in this file is #if !VAR, which includes the lines
  91. % after the #if only if VAR is zero.
  92. %
  93. % Convention: Use all uppercase identifiers for these preprocessor variables
  94. % so you can spot them easily
  95. %
  96. % The command line to the preprocessor should define one of PLAIN, UNSRT, ALPHA
  97. % or ABBRV (though PLAIN will be used by default if none is given),
  98. % and the following lines will set various boolean variables to control the
  99. % various lines that are chosen from the rest of the file.
  100. % Each boolean variable should be set true (1) or false (0) in each style.
  101. % Here are the current variables, and their meanings:
  102. %    0:    an alphabetic label is used (if false then a numeric
  103. %                label is used)
  104. %    0:        the entries should be sorted by label (if nonnumeric)
  105. %                and other info, like authors (if false, then
  106. %                entries remain in order of occurrence)
  107. %    0:    the authors, editors, etc., get the full names as
  108. %                given in the bibliography file (if false, the first
  109. %                names become initials)
  110. %    1:    titles of non-"books" (e.g., articles) should be
  111. %                converted to lower-case, except the first letter or
  112. %                first letter after a colon
  113. %                (if false then they appear as in the database)
  114. %    0:    months are spelled out in full (if false, then
  115. %                they're abbreviated)
  116. %    0:    macro journal names are spelled out in full
  117. %                (if false then they are abbreviated, currently
  118. %                as they appear in ACM publications)
  119. %#        define PLAIN 1
  120. %
  121. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  122. %    in "A Handbook for Scholars".  Book-like titles are italicized
  123. %    (emphasized) and non-book titles are converted to sentence
  124. %    capitilization (and not enclosed in quotes).
  125. %    This file outputs a \newblock between major blocks of an entry
  126. %    (the name \newblock is analogous to the names \newline and \newpage)
  127. %    so that the user can obtain an "open" format, which has a line break
  128. %    before each block and lines after the first are indented within blocks,
  129. %    by giving the optional \documentstyle argument `openbib';
  130. %    The default is the "closed" format---blocks runs together.
  131. %
  132. %   Citation alphabetic label format:
  133. %        [Knu73] for single author (or editor or key)
  134. %        [AHU83] (first letters of last names) for multiple authors
  135. %
  136. %   Citation label numberic format:
  137. %        [number]
  138. %
  139. %   Reference list ordering for sorted, alphabetic lables:
  140. %        alphabetical by citation label, then by author(s) or whatever
  141. %        passes for author in the absence of one, then by year,
  142. %        then title
  143. %
  144. %   Reference list ordering for sorted, numeric lables:
  145. %        alphabetical by author(s) or whatever passes
  146. %        for author in the absence of one, then by year, then title
  147. %
  148. %   Reference list ordering for unsorted:
  149. %        by the order cited in the text
  150. %
  151. %   History
  152. %   12/16/84    (HWT)    Original `plain' version, by Howard Trickey.
  153. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  154. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik.
  155. %    2/17/85    (HWT)    Template file and other standard styles made.
  156. %    3/28/85    (OP)    First release, version 0.98b for BibTeX 0.98f.
  157. %    5/ 9/85    (OP)    Version 0.98c for BibTeX 0.98i:
  158. %            fixed Theoretical Computer Science macro name;
  159. %            fixed the format.vol.num.pages function.
  160. %    1/24/88    (OP)    Version 0.99a for BibTeX 0.99a, main changes:
  161. %            assignment operator (:=) arguments reversed;
  162. %            the preamble$ function outputs the database PREAMBLE;
  163. %            entry.max$ and global.max$ (built-in) variables replace
  164. %            entry.string.max and global.string.max functions;
  165. %            alphabetizing by year then title, not just title;
  166. %            many unnecessary ties removed; \it ==> \em;
  167. %            the `alpha' style uses a superscripted `+' instead of a
  168. %            `*' for unnamed names in constructing the label;
  169. %            the `abbrv' style now uses "Mar." and "Sept.";
  170. %            the functions calc.label and presort now look at just
  171. %            the fields they're supposed to;
  172. %            BOOKLET, MASTERSTHESIS, TECHREPORT use nonbook titles;
  173. %            INBOOK and INCOLLECTION take an optional type (e.g.
  174. %            type = "Section"), overriding the default "chapter";
  175. %            BOOK, INBOOK, INCOLLECTION, and PROCEEDINGS now allow
  176. %            either volume or number, not just volume;
  177. %            INCOLLECTION now allows an edition and series field;
  178. %            PROCEEDINGS and INPROCEEDINGS now use the address field
  179. %            to tell where a conference was held;
  180. %            INPROCEEDINGS and PROCEEDINGS now allow either volume
  181. %            or number, and also a series field;
  182. %            MASTERSTHESIS and PHDTHESIS accept types other than
  183. %            "Master's thesis" and "PhD thesis";
  184. %            UNPUBLISHED now outputs, in one block, note then date;
  185. %            MANUAL now prints out the organization in
  186. %            the first block if the author field is empty;
  187. %            MISC can't be empty---it requires some optional field.
  188. %    3/23/88    (OP)    Version 0.99b for BibTeX 0.99c---changed the three
  189. %            erroneous occurrences of `cite ' to `cite$ '; this
  190. %            change didn't affect the four standard styles, so the
  191. %            0.99a versions of those styles are still current.
  192. %
  193. % The ENTRY declaration
  194. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  195. %   but no fullauthor or editors fields because BibTeX does name handling.
  196. %   The annote field is commented out here because this family doesn't
  197. %   include an annotated bibliography style.  And in addition to the fields
  198. %   listed here, BibTeX has a built-in crossref field, explained later.
  199. ENTRY
  200. % Fields:
  201.   { address
  202. %        Usually the address of a publisher or other type of organization.
  203. %        Put information in this field only if it helps the reader find the
  204. %        thing---for example you should omit the address of a major
  205. %        publisher entirely.  For a PROCEEDINGS or an INPROCEEDINGS,
  206. %        however, it's the address of the conference; for those two entry
  207. %        types, include the publisher's or organization's address, if
  208. %        necessary, in the publisher or organization field.
  209. %    annote
  210. %        Long annotation---for annotated bibliographies (begins sentence).
  211.     author
  212. %        Name(s) of author(s), in BibTeX name format.
  213.     booktitle
  214. %        Book title when the thing being referenced isn't the whole book.
  215. %        For book entries, the title field should be used instead.
  216.     chapter
  217. %        Chapter (or section or whatever) number.
  218.     edition
  219. %        Edition of a book---should be an ordinal (e.g., "Second").
  220.     editor
  221. %        Name(s) of editor(s), in BibTeX name format.
  222. %        If there is also an author field, then the editor field should be
  223. %        for the book or collection that the work appears in.
  224.     howpublished
  225. %         How something strange has been published (begins sentence).
  226.     institution
  227. %        Sponsoring institution of a technical report.
  228.     journal
  229. %        Journal name (macros are provided for many).
  230.     key
  231. %        Alphabetizing, labeling, and cross-referencing key
  232. %        (needed when an entry has no author or editor).
  233.     month
  234. %        Month (macros are provided).
  235.     note
  236. %        To help the reader find a reference (begins sentence).
  237.     number
  238. %        Number of a journal or technical report, or of a work in a series.
  239.     organization
  240. %        Organization sponsoring a conference (or publishing a manual); if
  241. %        the editor (or author) is empty, and if the organization produces
  242. %        an awkward label or cross reference, you should put appropriately
  243. %        condensed organization information in the key field as well.
  244.     pages
  245. %        Page number or numbers (use `--' to separate a range, use `+'
  246. %        to indicate pages following that don't form a simple range).
  247.     publisher
  248. %        Publisher name.
  249.     school
  250. %        School name (for theses).
  251.     series
  252. %        The name of a series or set of books.
  253. %        An individual book will will also have it's own title.
  254.     title
  255. %        The title of the thing you're referred to.
  256.     type
  257. %        Type of a Techreport (e.g., "Research Note") to be used instead of
  258. %        the default "Technical Report"; or, similarly, the type of a
  259. %        thesis; or of a part of a book.
  260.     volume
  261. %        The volume number of a journal or multivolume work.
  262.     year
  263. %        The year should contain only numerals (technically, it should end
  264. %        with four numerals, after purification; doesn't a begin sentence).
  265.   }
  266. % There are no integer entry variables
  267.   {}
  268. % These string entry variables are used to form the citation label.
  269. % In a storage pinch, sort.label can be easily computed on the fly.
  270.   { label }
  271. % Each entry function starts by calling output.bibitem, to write the
  272. % \bibitem and its arguments to the .BBL file.  Then the various fields
  273. % are formatted and printed by output or output.check.  Those functions
  274. % handle the writing of separators (commas, periods, \newblock's),
  275. % taking care not to do so when they are passed a null string.
  276. % Finally, fin.entry is called to add the final period and finish the
  277. % entry.
  278. %
  279. % A bibliographic reference is formatted into a number of `blocks':
  280. % in the open format, a block begins on a new line and subsequent
  281. % lines of the block are indented.  A block may contain more than
  282. % one sentence (well, not a grammatical sentence, but something to
  283. % be ended with a sentence ending period).  The entry functions should
  284. % call new.block whenever a block other than the first is about to be
  285. % started.  They should call new.sentence whenever a new sentence is
  286. % to be started.  The output functions will ensure that if two
  287. % new.sentence's occur without any non-null string being output between
  288. % them then there won't be two periods output.  Similarly for two
  289. % successive new.block's.
  290. %
  291. % The output routines don't write their argument immediately.
  292. % Instead, by convention, that argument is saved on the stack to be
  293. % output next time (when we'll know what separator needs to come
  294. % after it).  Meanwhile, the output routine has to pop the pending
  295. % output off the stack, append any needed separator, and write it.
  296. %
  297. % To tell which separator is needed, we maintain an output.state.
  298. % It will be one of these values:
  299. %    before.all        just after the \bibitem
  300. %    mid.sentence        in the middle of a sentence: comma needed
  301. %                    if more sentence is output
  302. %    after.sentence        just after a sentence: period needed
  303. %    after.block        just after a block (and sentence):
  304. %                    period and \newblock needed.
  305. % Note: These styles don't use after.sentence
  306. %
  307. % VAR: output.state : INTEGER        -- state variable for output
  308. %
  309. % The output.nonnull function saves its argument (assumed to be nonnull)
  310. % on the stack, and writes the old saved value followed by any needed
  311. % separator.  The ordering of the tests is decreasing frequency of
  312. % occurrence.
  313. %
  314. % output.nonnull(s) ==
  315. %  BEGIN
  316. %    s := argument on stack
  317. %    if output.state = mid.sentence then
  318. %        write$(pop() * ", ")
  319. %          -- "pop" isn't a function: just use stack top
  320. %    else
  321. %        if output.state = after.block then
  322. %        write$(add.period$(pop()))
  323. %        newline$
  324. %        write$("\newblock ")
  325. %        else
  326. %        if output.state = before.all then
  327. %            write$(pop())
  328. %        else        -- output.state should be after.sentence
  329. %            write$(add.period$(pop()) * " ")
  330. %        fi
  331. %        fi
  332. %        output.state := mid.sentence
  333. %    fi
  334. %    push s on stack
  335. %  END
  336. %
  337. % The output function calls output.nonnull if its argument is non-empty;
  338. % its argument may be a missing field (thus, not necessarily a string)
  339. %
  340. % output(s) ==
  341. %  BEGIN
  342. %    if not empty$(s) then output.nonnull(s)
  343. %    fi
  344. %  END
  345. %
  346. % The output.check function is the same as the output function except that, if
  347. % necessary, output.check warns the user that the t field shouldn't be empty
  348. % (this is because it probably won't be a good reference without the field;
  349. % the entry functions try to make the formatting look reasonable even when
  350. % such fields are empty).
  351. %
  352. % output.check(s,t) ==
  353. %  BEGIN
  354. %    if empty$(s) then
  355. %        warning$("empty " * t * " in " * cite$)
  356. %    else output.nonnull(s)
  357. %    fi
  358. %  END
  359. %
  360. % The output.bibitem function writes the \bibitem for the current entry
  361. % (the label should already have been set up), and sets up the separator
  362. % state for the output functions.  And, it leaves a string on the stack
  363. % as per the output convention.
  364. %
  365. % output.bibitem ==
  366. %  BEGIN
  367. %    newline$
  368. %    write$("\bibitem[")    % for alphabetic labels,
  369. %    write$(label)        % these three lines
  370. %    write$("]{")        % are used
  371. %    write$("\bibitem{")        % this line for numeric labels
  372. %    write$(cite$)
  373. %    write$("}")
  374. %    push "" on stack
  375. %    output.state := before.all
  376. %  END
  377. %
  378. % The fin.entry function finishes off an entry by adding a period to the
  379. % string remaining on the stack.  If the state is still before.all
  380. % then nothing was produced for this entry, so the result will look bad,
  381. % but the user deserves it. (We don't omit the whole entry because the
  382. % entry was cited, and a bibitem is needed to define the citation label.)
  383. %
  384. % fin.entry ==
  385. %  BEGIN
  386. %    write$(add.period$(pop()))
  387. %    newline$
  388. %  END
  389. %
  390. % The new.block function prepares for a new block to be output, and
  391. % new.sentence prepares for a new sentence.
  392. %
  393. % new.block ==
  394. %  BEGIN
  395. %    if output.state <> before.all then
  396. %        output.state := after.block
  397. %    fi
  398. %  END
  399. %
  400. % new.sentence ==
  401. %  BEGIN
  402. %    if output.state <> after.block then
  403. %        if output.state <> before.all then
  404. %        output.state :=  after.sentence
  405. %        fi
  406. %    fi
  407. %  END
  408. %
  409. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  410. FUNCTION {init.state.consts}
  411. { #0 'before.all :=
  412.   #1 'mid.sentence :=
  413.   #2 'after.sentence :=
  414.   #3 'after.block :=
  415. }
  416. % the variables s and t are temporary string holders
  417. STRINGS { s t }
  418. FUNCTION {output.nonnull}
  419. { 's :=
  420.   output.state mid.sentence =
  421.     { ", " * write$ }
  422.     { output.state after.block =
  423.     { "," * write$
  424.       newline$
  425.       "\newblock " write$
  426.     }
  427.     { output.state before.all =
  428.         'write$
  429.         { add.period$ " " * write$ }
  430.       if$
  431.     }
  432.       if$
  433.       mid.sentence 'output.state :=
  434.     }
  435.   if$
  436.   s
  437. }
  438. FUNCTION {output}
  439. { duplicate$ empty$
  440.     'pop$
  441.     'output.nonnull
  442.   if$
  443. }
  444. FUNCTION {output.check}
  445. { 't :=
  446.   duplicate$ empty$
  447.     { pop$ "empty " t * " in " * cite$ * warning$ }
  448.     'output.nonnull
  449.   if$
  450. }
  451. FUNCTION {output.bibitem}
  452. { newline$
  453.   "\bibitem{" write$
  454.   cite$ write$
  455.   "}" write$
  456.   newline$
  457.   ""
  458.   before.all 'output.state :=
  459. }
  460. % This function finishes all entries.
  461. FUNCTION {fin.entry}
  462. { add.period$
  463.   write$
  464.   newline$
  465. }
  466. FUNCTION {new.block}
  467. { output.state before.all =
  468.     'skip$
  469.     { after.block 'output.state := }
  470.   if$
  471. }
  472. FUNCTION {new.sentence}
  473. { skip$
  474. }
  475. % These three functions pop one or two (integer) arguments from the stack
  476. % and push a single one, either 0 or 1.
  477. % The 'skip$ in the `and' and `or' functions are used because
  478. % the corresponding if$ would be idempotent
  479. FUNCTION {not}
  480. {   { #0 }
  481.     { #1 }
  482.   if$
  483. }
  484. FUNCTION {and}
  485. {   'skip$
  486.     { pop$ #0 }
  487.   if$
  488. }
  489. FUNCTION {or}
  490. {   { pop$ #1 }
  491.     'skip$
  492.   if$
  493. }
  494. % Sometimes we begin a new block only if the block will be big enough.  The
  495. % new.block.checka function issues a new.block if its argument is nonempty;
  496. % new.block.checkb does the same if either of its TWO arguments is nonempty.
  497. FUNCTION {new.block.checka}
  498. { empty$
  499.     'skip$
  500.     'new.block
  501.   if$
  502. }
  503. FUNCTION {new.block.checkb}
  504. { empty$
  505.   swap$ empty$
  506.   and
  507.     'skip$
  508.     'new.block
  509.   if$
  510. }
  511. % The new.sentence.check functions are analogous.
  512. FUNCTION {new.sentence.checka}
  513. { empty$
  514.     'skip$
  515.     'new.sentence
  516.   if$
  517. }
  518. FUNCTION {new.sentence.checkb}
  519. { empty$
  520.   swap$ empty$
  521.   and
  522.     'skip$
  523.     'new.sentence
  524.   if$
  525. }
  526. % Here are some functions for formatting chunks of an entry.
  527. % By convention they either produce a string that can be followed by
  528. % a comma or period (using add.period$, so it is OK to end in a period),
  529. % or they produce the null string.
  530. %
  531. % A useful utility is the field.or.null function, which checks if the
  532. % argument is the result of pushing a `missing' field (one for which no
  533. % assignment was made when the current entry was read in from the database)
  534. % or the result of pushing a string having no non-white-space characters.
  535. % It returns the null string if so, otherwise it returns the field string.
  536. % Its main (but not only) purpose is to guarantee that what's left on the
  537. % stack is a string rather than a missing field.
  538. %
  539. % field.or.null(s) ==
  540. %  BEGIN
  541. %    if empty$(s) then return ""
  542. %    else return s
  543. %  END
  544. %
  545. % Another helper function is emphasize, which returns the argument emphazised,
  546. % if that is non-empty, otherwise it returns the null string.  Italic
  547. % corrections aren't used, so this function should be used when punctation
  548. % will follow the result.
  549. %
  550. % emphasize(s) ==
  551. %  BEGIN
  552. %    if empty$(s) then return ""
  553. %    else return "{\em " * s * "}"
  554. %
  555. % The format.names function formats the argument (which should be in
  556. % BibTeX name format) into "First Von Last, Junior", separated by commas
  557. % and with an "and" before the last (but ending with "et~al." if the last
  558. % of multiple authors is "others").  This function's argument should always
  559. % contain at least one name.
  560. %
  561. % VAR: nameptr, namesleft, numnames: INTEGER
  562. % pseudoVAR: nameresult: STRING        (it's what's accumulated on the stack)
  563. %
  564. % format.names(s) ==
  565. %  BEGIN
  566. %    nameptr := 1
  567. %    numnames := num.names$(s)
  568. %    namesleft := numnames
  569. %    while namesleft > 0
  570. %      do
  571. %                % for full names:
  572. %        t := format.name$(s, nameptr, "{ff~}{vv~}{ll}{, jj}")
  573. %                % for abbreviated first names:
  574. %        t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  575. %        if nameptr > 1 then
  576. %        if namesleft > 1 then nameresult := nameresult * ", " * t
  577. %        else if numnames > 2
  578. %               then nameresult := nameresult * ","
  579. %             fi
  580. %             if t = "others"
  581. %               then nameresult := nameresult * " et~al."
  582. %               else nameresult := nameresult * " and " * t
  583. %             fi
  584. %        fi
  585. %        else nameresult := t
  586. %        fi
  587. %        nameptr := nameptr + 1
  588. %        namesleft := namesleft - 1
  589. %      od
  590. %    return nameresult
  591. %  END
  592. %
  593. % The format.authors function returns the result of format.names(author)
  594. % if the author is present, or else it returns the null string
  595. %
  596. % format.authors ==
  597. %  BEGIN
  598. %    if empty$(author) then return ""
  599. %    else return format.names(author)
  600. %    fi
  601. %  END
  602. %
  603. % Format.editors is like format.authors, but it uses the editor field,
  604. % and appends ", editor" or ", editors"
  605. %
  606. % format.editors ==
  607. %  BEGIN
  608. %    if empty$(editor) then return ""
  609. %    else
  610. %        if num.names$(editor) > 1 then
  611. %        return format.names(editor) * ", editors"
  612. %        else
  613. %        return format.names(editor) * ", editor"
  614. %        fi
  615. %    fi
  616. %  END
  617. %
  618. % Other formatting functions are similar, so no "comment version" will be
  619. % given for them.
  620. %
  621. % The `pop$' in this function gets rid of the duplicate `empty' value and
  622. % the `skip$' returns the duplicate field value
  623. FUNCTION {field.or.null}
  624. { duplicate$ empty$
  625.     { pop$ "" }
  626.     'skip$
  627.   if$
  628. }
  629. FUNCTION {emphasize}
  630. { duplicate$ empty$
  631.     { pop$ "" }
  632.     { "{\em " swap$ * "}" * }
  633.   if$
  634. }
  635. FUNCTION {embolden}
  636. { duplicate$ empty$
  637.     { pop$ "" }
  638.     { "{\bf " swap$ * "}" * }
  639.   if$
  640. }
  641. FUNCTION {paren}
  642. { duplicate$ empty$
  643.     { pop$ "" }
  644.     { "(" swap$ * ")" * }
  645.   if$
  646. }
  647. INTEGERS { nameptr namesleft numnames }
  648. FUNCTION {format.names}
  649. { 's :=
  650.   #1 'nameptr :=
  651.   s num.names$ 'numnames :=
  652.   numnames 'namesleft :=
  653.     { namesleft #0 > }
  654.     { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
  655.       nameptr #1 >
  656.     { namesleft #1 >
  657.         { ", " * t * }
  658.         { numnames #2 >
  659.         { "," * }
  660.         'skip$
  661.           if$
  662.           t "others" =
  663.         { " et~al." * }
  664.         { " and " * t * }
  665.           if$
  666.         }
  667.       if$
  668.     }
  669.     't
  670.       if$
  671.       nameptr #1 + 'nameptr :=
  672.       namesleft #1 - 'namesleft :=
  673.     }
  674.   while$
  675. }
  676. FUNCTION {format.authors}
  677. { author empty$
  678.     { "" }
  679.     { author format.names }
  680.   if$
  681. }
  682. FUNCTION {format.editors}
  683. { editor empty$
  684.     { "" }
  685.     { editor format.names
  686.       editor num.names$ #1 >
  687.     { ", editors" * }
  688.     { ", editor" * }
  689.       if$
  690.     }
  691.   if$
  692. }
  693. FUNCTION {format.edited}
  694. { editor empty$
  695.     { "" }
  696.     { "edited by " editor format.names * }
  697.   if$
  698. }
  699. % The format.title function is used for non-book-like titles.
  700. % For most styles we convert to lowercase (except for the very first letter,
  701. % and except for the first one after a colon (followed by whitespace)),
  702. % and hope the user has brace-surrounded words that need to stay capitilized;
  703. % for some styles, however, we leave it as it is in the database.
  704. FUNCTION {format.title}
  705. { title empty$
  706.     { "" }
  707.     { title "t" change.case$ }
  708.   if$
  709. }
  710. % By default, BibTeX sets the global integer variable global.max$ to the BibTeX
  711. % constant glob_str_size, the maximum length of a global string variable.
  712. % Analogously, BibTeX sets the global integer variable entry.max$ to
  713. % ent_str_size, the maximum length of an entry string variable.
  714. % The style designer may change these if necessary (but this is unlikely)
  715. % The n.dashify function makes each single `-' in a string a double `--'
  716. % if it's not already
  717. %
  718. % pseudoVAR: pageresult: STRING        (it's what's accumulated on the stack)
  719. %
  720. % n.dashify(s) ==
  721. %  BEGIN
  722. %    t := s
  723. %    pageresult := ""
  724. %    while (not empty$(t))
  725. %      do
  726. %        if (first character of t = "-")
  727. %          then
  728. %        if (next character isn't)
  729. %          then
  730. %            pageresult := pageresult * "--"
  731. %            t := t with the "-" removed
  732. %          else
  733. %            while (first character of t = "-")
  734. %              do
  735. %            pageresult := pageresult * "-"
  736. %            t := t with the "-" removed
  737. %              od
  738. %        fi
  739. %          else
  740. %        pageresult := pageresult * the first character
  741. %        t := t with the first character removed
  742. %        fi
  743. %      od
  744. %    return pageresult
  745. %  END
  746. FUNCTION {n.dashify}
  747. { 't :=
  748.   ""
  749.     { t empty$ not }
  750.     { t #1 #1 substring$ "-" =
  751.     { t #1 #2 substring$ "--" = not
  752.         { "--" *
  753.           t #2 global.max$ substring$ 't :=
  754.         }
  755.         {   { t #1 #1 substring$ "-" = }
  756.         { "-" *
  757.           t #2 global.max$ substring$ 't :=
  758.         }
  759.           while$
  760.         }
  761.       if$
  762.     }
  763.     { t #1 #1 substring$ *
  764.       t #2 global.max$ substring$ 't :=
  765.     }
  766.       if$
  767.     }
  768.   while$
  769. }
  770. FUNCTION {first.page}
  771. { 't :=
  772.   ""
  773.     {  t empty$ not t #1 #1 substring$ "-" = not and }
  774.     { t #1 #1 substring$ *
  775.       t #2 global.max$ substring$ 't :=
  776.     }
  777.   while$
  778. }
  779. % The format.date function is for the month and year, but we give a warning if
  780. % there's an empty year but the month is there, and we return the empty string
  781. % if they're both empty.
  782. FUNCTION {format.date}
  783. { year empty$
  784.     { "" }
  785.     'year
  786.   if$
  787. }
  788. % The format.btitle is for formatting the title field when it is a book-like
  789. % entry---the style used here keeps it in uppers-and-lowers and emphasizes it.
  790. FUNCTION {format.btitle}
  791. { title emphasize
  792. }
  793. % For several functions we'll need to connect two strings with a
  794. % tie (~) if the second one isn't very long (fewer than 3 characters).
  795. % The tie.or.space.connect function does that.  It concatenates the two
  796. % strings on top of the stack, along with either a tie or space between
  797. % them, and puts this concatenation back onto the stack:
  798. %
  799. % tie.or.space.connect(str1,str2) ==
  800. %    BEGIN
  801. %    if text.length$(str2) < 3
  802. %      then return the concatenation of str1, "~", and str2
  803. %      else return the concatenation of str1, " ", and str2
  804. %    END
  805. FUNCTION {tie.or.space.connect}
  806. { duplicate$ text.length$ #3 <
  807.     { "~" }
  808.     { " " }
  809.   if$
  810.   swap$ * *
  811. }
  812. % The either.or.check function complains if both fields or an either-or pair
  813. % are nonempty.
  814. %
  815. % either.or.check(t,s) ==
  816. %  BEGIN
  817. %    if empty$(s) then
  818. %        warning$(can't use both " * t * " fields in " * cite$)
  819. %    fi
  820. %  END
  821. FUNCTION {either.or.check}
  822. { empty$
  823.     'pop$
  824.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  825.   if$
  826. }
  827. % The format.bvolume function is for formatting the volume and perhaps
  828. % series name of a multivolume work.  If both a volume and a series field
  829. % are there, we assume the series field is the title of the whole multivolume
  830. % work (the title field should be the title of the thing being referred to),
  831. % and we add an "of <series>".  This function is called in mid-sentence.
  832. FUNCTION {format.bvolume}
  833. { volume empty$
  834.     { "" }
  835.     { "volume" volume tie.or.space.connect
  836.       series empty$
  837.     'skip$
  838.     { " of " * series emphasize * }
  839.       if$
  840.       "volume and number" number either.or.check
  841.     }
  842.   if$
  843. }
  844. % The format.number.series function is for formatting the series name
  845. % and perhaps number of a work in a series.  This function is similar to
  846. % format.bvolume, although for this one the series must exist (and the
  847. % volume must not exist).  If the number field is empty we output either
  848. % the series field unchanged if it exists or else the null string.
  849. % If both the number and series fields are there we assume the series field
  850. % gives the name of the whole series (the title field should be the title
  851. % of the work being one referred to), and we add an "in <series>".
  852. % We capitilize Number when this function is used at the beginning of a block.
  853. FUNCTION {format.number.series}
  854. { volume empty$
  855.     { number empty$
  856.     { series field.or.null }
  857.     { output.state mid.sentence =
  858.         { "number" }
  859.         { "Number" }
  860.       if$
  861.       number tie.or.space.connect
  862.       series empty$
  863.         { "there's a number but no series in " cite$ * warning$ }
  864.         { " in " * series * }
  865.       if$
  866.     }
  867.       if$
  868.     }
  869.     { "" }
  870.   if$
  871. }
  872. % The format.edition function appends " edition" to the edition, if present.
  873. % We lowercase the edition (it should be something like "Third"), because
  874. % this doesn't start a sentence.
  875. FUNCTION {format.edition}
  876. { edition empty$
  877.     { "" }
  878.     { output.state mid.sentence =
  879.     { edition "l" change.case$ " edition" * }
  880.     { edition "t" change.case$ " edition" * }
  881.       if$
  882.     }
  883.   if$
  884. }
  885. % The format.pages function is used for formatting a page range in a book
  886. % (and in rare circumstances, an article).
  887. %
  888. % The multi.page.check function examines the page field for a "-" or "," or "+"
  889. % so that format.pages can use "page" instead of "pages" if none exists.
  890. % Note: global.max$ here means "take the rest of the string"
  891. %
  892. % VAR: multiresult: INTEGER    (actually, a boolean)
  893. %
  894. % multi.page.check(s) ==
  895. %  BEGIN
  896. %    t := s
  897. %    multiresult := false
  898. %    while ((not multiresult) and (not empty$(t)))
  899. %      do
  900. %        if (first character of t = "-" or "," or "+")
  901. %          then multiresult := true
  902. %          else t := t with the first character removed
  903. %        fi
  904. %      od
  905. %    return multiresult
  906. %  END
  907. INTEGERS { multiresult }
  908. FUNCTION {multi.page.check}
  909. { 't :=
  910.   #0 'multiresult :=
  911.     { multiresult not
  912.       t empty$ not
  913.       and
  914.     }
  915.     { t #1 #1 substring$
  916.       duplicate$ "-" =
  917.       swap$ duplicate$ "," =
  918.       swap$ "+" =
  919.       or or
  920.     { #1 'multiresult := }
  921.     { t #2 global.max$ substring$ 't := }
  922.       if$
  923.     }
  924.   while$
  925.   multiresult
  926. }
  927. % This function doesn't begin a sentence so "pages" isn't capitalized.
  928. % Other functions that use this should keep that in mind.
  929. FUNCTION {format.pages}
  930. { pages empty$
  931.     { "" }
  932.     { pages multi.page.check
  933.     { "pp." pages n.dashify tie.or.space.connect }
  934.     { "p." pages tie.or.space.connect }
  935.       if$
  936.     }
  937.   if$
  938. }
  939. FUNCTION {format.pages.a}
  940. { pages empty$
  941.     { "" }
  942.     { "p." pages first.page tie.or.space.connect }
  943.   if$
  944. }
  945. % The format.vol.num.pages function is for the volume, number, and page range
  946. % of a journal article.  We use the format:  vol(number):pages, with some
  947. % variations for empty fields.  This doesn't begin a sentence.
  948. FUNCTION {format.vol.num.pages}
  949. { volume field.or.null embolden
  950.   " " swap$ * *
  951.   pages empty$
  952.     'skip$
  953.     { duplicate$ empty$
  954.     { pop$ format.pages.a }
  955.     { ", " * pages first.page * }
  956.       if$
  957.     }
  958.   if$
  959. }
  960. % The format.chapter.pages, if the chapter is present, puts whatever is in the
  961. % type field (or else "chapter" if type is empty) in front of a chapter number.
  962. % It then appends the pages, if present.  This doesn't begin a sentence.
  963. FUNCTION {format.chapter.pages}
  964. { chapter empty$
  965.     'format.pages
  966.     { type empty$
  967.     { "chapter" }
  968.     { type "l" change.case$ }
  969.       if$
  970.       chapter tie.or.space.connect
  971.       pages empty$
  972.     'skip$
  973.     { ", " * format.pages * }
  974.       if$
  975.     }
  976.   if$
  977. }
  978. % The format.in.ed.booktitle function is used for starting out a sentence
  979. % that begins "In <booktitle>", putting an editor before the title if one
  980. % exists.
  981. FUNCTION {format.in.ed.booktitle}
  982. { booktitle empty$
  983.     { "" }
  984.     { editor empty$
  985.     { "in " booktitle emphasize * }
  986.     { "in " booktitle emphasize * ", " * format.edited * }
  987.       if$
  988.     }
  989.   if$
  990. }
  991. % The function empty.misc.check complains if all six fields are empty, and
  992. % if there's been no sorting or alphabetic-label complaint.
  993. FUNCTION {empty.misc.check}
  994. { author empty$ title empty$ howpublished empty$
  995.   month empty$ year empty$ note empty$
  996.   and and and and and
  997.     { "all relevant fields are empty in " cite$ * warning$ }
  998.     'skip$
  999.   if$
  1000. }
  1001. % The function format.thesis.type returns either the (case-changed) type field,
  1002. % if it is defined, or else the default string already on the stack
  1003. % (like "Master's thesis" or "PhD thesis").
  1004. FUNCTION {format.thesis.type}
  1005. { type empty$
  1006.     'skip$
  1007.     { pop$
  1008.       type "t" change.case$
  1009.     }
  1010.   if$
  1011. }
  1012. % The function format.tr.number makes a string starting with "Technical Report"
  1013. % (or type, if that field is defined), followed by the number if there is one;
  1014. % it returns the starting part (with a case change) even if there is no number.
  1015. % This is used at the beginning of a sentence.
  1016. FUNCTION {format.tr.number}
  1017. { type empty$
  1018.     { "Technical Report" }
  1019.     'type
  1020.   if$
  1021.   number empty$
  1022.     { "t" change.case$ }
  1023.     { number tie.or.space.connect }
  1024.   if$
  1025. }
  1026. % Now come the cross-referencing functions (these are invoked because
  1027. % one entry in the database file(s) cross-references another, by giving
  1028. % the other entry's database key in a `crossref' field).  This feature
  1029. % allows one or more titled things that are part of a larger titled
  1030. % thing to cross-reference the larger thing.  These styles allow for
  1031. % five posibilities: (1) an ARTICLE may cross-reference an ARTICLE;
  1032. % (2) a BOOK, (3) INBOOK, or (4) INCOLLECTION may cross-reference a BOOK;
  1033. % or (5) an INPROCEEDINGS may cross-reference a PROCEEDINGS.
  1034. % Each of these is explained in more detail later.
  1035. %
  1036. % An ARTICLE entry type may cross reference another ARTICLE (this is
  1037. % intended for when an entire journal is devoted to a single topic---
  1038. % but since there is no JOURNAL entry type, the journal, too, should be
  1039. % classified as an ARTICLE but without the author and title fields).
  1040. % This will result in two warning messages for the journal's entry
  1041. % if it's included in the reference list, but such is life.
  1042. %
  1043. % format.article.crossref ==
  1044. %  BEGIN
  1045. %    if empty$(key) then
  1046. %        if empty$(journal) then
  1047. %        warning$("need key or journal for " * cite$ *
  1048. %                        " to crossref " * crossref)
  1049. %        return(" \cite{" * crossref * "}")
  1050. %        else
  1051. %        return("In " * emphazise.correct (journal) *
  1052. %                        " \cite{" * crossref * "}")
  1053. %        fi
  1054. %    else
  1055. %        return("In " * key * " \cite{" * crossref * "}")
  1056. %    fi
  1057. %  END
  1058. %
  1059. % The other cross-referencing functions are similar, so no "comment version"
  1060. % will be given for them.
  1061. FUNCTION {format.article.crossref}
  1062. { key empty$
  1063.     { journal empty$
  1064.     { "need key or journal for " cite$ * " to crossref " * crossref *
  1065.       warning$
  1066.       ""
  1067.     }
  1068.     { "In " journal * }
  1069.       if$
  1070.     }
  1071.     { "In " key * }
  1072.   if$
  1073.   " \cite{" * crossref * "}" *
  1074. }
  1075. % We use just the last names of editors for a cross reference: either
  1076. % "editor", or "editor1 and editor2", or "editor1 et~al." depending on
  1077. % whether there are one, or two, or more than two editors.
  1078. FUNCTION {format.crossref.editor}
  1079. { editor #1 "{vv~}{ll}" format.name$
  1080.   editor num.names$ duplicate$
  1081.   #2 >
  1082.     { pop$ " et~al." * }
  1083.     { #2 <
  1084.     'skip$
  1085.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1086.         { " et~al." * }
  1087.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  1088.       if$
  1089.     }
  1090.       if$
  1091.     }
  1092.   if$
  1093. }
  1094. % A BOOK (or INBOOK) entry type (assumed to be for a single volume in a
  1095. % multivolume work) may cross reference another BOOK (the entire multivolume).
  1096. % Usually there will be an editor, in which case we use that to construct the
  1097. % cross reference; otherwise we use a nonempty key field or else the series
  1098. % field (since the series gives the title of the multivolume work).
  1099. FUNCTION {format.book.crossref}
  1100. { volume empty$
  1101.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  1102.       "In "
  1103.     }
  1104.     { "Volume" volume tie.or.space.connect
  1105.       " of " *
  1106.     }
  1107.   if$
  1108.   editor empty$
  1109.   editor field.or.null author field.or.null =
  1110.   or
  1111.     { key empty$
  1112.     { series empty$
  1113.         { "need editor, key, or series for " cite$ * " to crossref " *
  1114.           crossref * warning$
  1115.           "" *
  1116.         }
  1117.         { "{\em " * series * "\/}" * }
  1118.       if$
  1119.     }
  1120.     { key * }
  1121.       if$
  1122.     }
  1123.     { format.crossref.editor * }
  1124.   if$
  1125.   " \cite{" * crossref * "}" *
  1126. }
  1127. % An INCOLLECTION entry type may cross reference a BOOK (assumed to be the
  1128. % collection), or an INPROCEEDINGS may cross reference a PROCEEDINGS.
  1129. % Often there will be an editor, in which case we use that to construct
  1130. % the cross reference; otherwise we use a nonempty key field or else
  1131. % the booktitle field (which gives the cross-referenced work's title).
  1132. FUNCTION {format.incoll.inproc.crossref}
  1133. { editor empty$
  1134.   editor field.or.null author field.or.null =
  1135.   or
  1136.     { key empty$
  1137.     { booktitle empty$
  1138.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  1139.           crossref * warning$
  1140.           ""
  1141.         }
  1142.         { "In {\em " booktitle * "\/}" * }
  1143.       if$
  1144.     }
  1145.     { "In " key * }
  1146.       if$
  1147.     }
  1148.     { "In " format.crossref.editor * }
  1149.   if$
  1150.   " \cite{" * crossref * "}" *
  1151. }
  1152. % Now we define the type functions for all entry types that may appear
  1153. % in the .BIB file---e.g., functions like `article' and `book'.  These
  1154. % are the routines that actually generate the .BBL-file output for
  1155. % the entry.  These must all precede the READ command.  In addition, the
  1156. % style designer should have a function `default.type' for unknown types.
  1157. % Note: The fields (within each list) are listed in order of appearance,
  1158. % except as described for an `inbook' or a `proceedings'.
  1159. %
  1160. % The article function is for an article in a journal.  An article may
  1161. % CROSSREF another article.
  1162. %    Required fields: author, title, journal, year
  1163. %    Optional fields: volume, number, pages, month, note
  1164. %
  1165. % article ==
  1166. %  BEGIN
  1167. %    output.bibitem
  1168. %    output.check(format.authors,"author")
  1169. %    new.block
  1170. %    output.check(format.title,"title")
  1171. %    new.block
  1172. %    if missing$(crossref) then
  1173. %        output.check(emphasize(journal),"journal")
  1174. %        output(format.vol.num.pages)
  1175. %        output.check(format.date,"year")
  1176. %       else
  1177. %        output.nonnull(format.article.crossref)
  1178. %        output(format.pages)
  1179. %    fi
  1180. %    new.block
  1181. %    output(note)
  1182. %    fin.entry
  1183. %  END
  1184. %
  1185. % The book function is for a whole book.  A book may CROSSREF another book.
  1186. %    Required fields: author or editor, title, publisher, year
  1187. %    Optional fields: volume or number, series, address, edition, month,
  1188. %            note
  1189. %
  1190. % book ==
  1191. %  BEGIN
  1192. %    if empty$(author) then output.check(format.editors,"author and editor")
  1193. %    else    output.check(format.authors,"author")
  1194. %        if missing$(crossref) then
  1195. %            either.or.check("author and editor",editor)
  1196. %        fi
  1197. %    fi
  1198. %    new.block
  1199. %    output.check(format.btitle,"title")
  1200. %    if missing$(crossref) then
  1201. %        output(format.bvolume)
  1202. %        new.block
  1203. %        output(format.number.series)
  1204. %        new.sentence
  1205. %        output.check(publisher,"publisher")
  1206. %        output(address)
  1207. %       else
  1208. %        new.block
  1209. %        output.nonnull(format.book.crossref)
  1210. %    fi
  1211. %    output(format.edition)
  1212. %    output.check(format.date,"year")
  1213. %    new.block
  1214. %    output(note)
  1215. %    fin.entry
  1216. %  END
  1217. %
  1218. % The other entry functions are all quite similar, so no "comment version"
  1219. % will be given for them.
  1220. FUNCTION {article}
  1221. { output.bibitem
  1222.   format.authors "author" output.check
  1223.   new.block
  1224.   crossref missing$
  1225.     { journal field.or.null
  1226.       format.vol.num.pages 
  1227.       format.date empty$
  1228.     'skip$
  1229.     { duplicate$ empty$
  1230.         { pop$ format.date paren }
  1231.             { " " * format.date paren * }
  1232.       if$
  1233.     }
  1234.       if$
  1235.       output
  1236.     }
  1237.     { format.article.crossref output.nonnull
  1238.       format.pages output
  1239.     }
  1240.   if$
  1241.   new.block
  1242.   note output
  1243.   fin.entry
  1244. }
  1245. FUNCTION {book}
  1246. { output.bibitem
  1247.   author empty$
  1248.     { format.editors "author and editor" output.check }
  1249.     { format.authors output.nonnull
  1250.       crossref missing$
  1251.     { "author and editor" editor either.or.check }
  1252.     'skip$
  1253.       if$
  1254.     }
  1255.   if$
  1256.   new.block
  1257.   format.btitle "title" output.check
  1258.   crossref missing$
  1259.     { format.bvolume output
  1260.       new.block
  1261.       format.number.series output
  1262.       new.sentence
  1263.       publisher "publisher" output.check
  1264.       address output
  1265.     }
  1266.     { new.block
  1267.       format.book.crossref output.nonnull
  1268.     }
  1269.   if$
  1270.   format.edition output
  1271.   format.date "year" output.check
  1272.   new.block
  1273.   note output
  1274.   fin.entry
  1275. }
  1276. % A booklet is a bound thing without a publisher or sponsoring institution.
  1277. %    Required: title
  1278. %    Optional: author, howpublished, address, month, year, note
  1279. FUNCTION {booklet}
  1280. { output.bibitem
  1281.   format.authors output
  1282.   new.block
  1283.   format.title "title" output.check
  1284.   howpublished address new.block.checkb
  1285.   howpublished output
  1286.   address output
  1287.   format.date output
  1288.   new.block
  1289.   note output
  1290.   fin.entry
  1291. }
  1292. % For the conference entry type, see inproceedings.
  1293. % An inbook is a piece of a book: either a chapter and/or a page range.
  1294. % It may CROSSREF a book.  If there's no volume field, the type field
  1295. % will come before number and series.
  1296. %    Required: author or editor, title, chapter and/or pages, publisher,year
  1297. %    Optional: volume or number, series, type, address, edition, month, note
  1298. FUNCTION {inbook}
  1299. { output.bibitem
  1300.   author empty$
  1301.     { format.editors "author and editor" output.check }
  1302.     { format.authors output.nonnull
  1303.       crossref missing$
  1304.     { "author and editor" editor either.or.check }
  1305.     'skip$
  1306.       if$
  1307.     }
  1308.   if$
  1309.   new.block
  1310.   format.btitle "title" output.check
  1311.   crossref missing$
  1312.     { format.bvolume output
  1313.       format.chapter.pages "chapter and pages" output.check
  1314.       new.block
  1315.       format.number.series output
  1316.       new.sentence
  1317.       publisher "publisher" output.check
  1318.       address output
  1319.     }
  1320.     { format.chapter.pages "chapter and pages" output.check
  1321.       new.block
  1322.       format.book.crossref output.nonnull
  1323.     }
  1324.   if$
  1325.   format.edition output
  1326.   format.date "year" output.check
  1327.   new.block
  1328.   note output
  1329.   fin.entry
  1330. }
  1331. % An incollection is like inbook, but where there is a separate title
  1332. % for the referenced thing (and perhaps an editor for the whole).
  1333. % An incollection may CROSSREF a book.
  1334. %    Required: author, title, booktitle, publisher, year
  1335. %    Optional: editor, volume or number, series, type, chapter, pages,
  1336. %            address, edition, month, note
  1337. FUNCTION {incollection}
  1338. { output.bibitem
  1339.   format.authors "author" output.check
  1340.   new.block
  1341.   crossref missing$
  1342.     { format.in.ed.booktitle "booktitle" output.check
  1343.       new.sentence
  1344.       publisher "publisher" output.check
  1345.       address output
  1346.       format.edition output
  1347.       format.date "year" output.check
  1348.       format.bvolume output
  1349.       format.number.series output
  1350.       format.chapter.pages output
  1351.     }
  1352.     { format.incoll.inproc.crossref output.nonnull
  1353.       format.chapter.pages output
  1354.     }
  1355.   if$
  1356.   new.block
  1357.   note output
  1358.   fin.entry
  1359. }
  1360. % An inproceedings is an article in a conference proceedings, and it may
  1361. % CROSSREF a proceedings.  If there's no address field, the month (& year)
  1362. % will appear just before note.
  1363. %    Required: author, title, booktitle, year
  1364. %    Optional: editor, volume or number, series, pages, address, month,
  1365. %            organization, publisher, note
  1366. FUNCTION {inproceedings}
  1367. { output.bibitem
  1368.   format.authors "author" output.check
  1369.   new.block
  1370.   format.title "title" output.check
  1371.   new.block
  1372.   crossref missing$
  1373.     { format.in.ed.booktitle "booktitle" output.check
  1374.       format.bvolume output
  1375.       format.number.series output
  1376.       format.pages output
  1377.       address empty$
  1378.     { organization publisher new.sentence.checkb
  1379.       organization output
  1380.       publisher output
  1381.       format.date "year" output.check
  1382.     }
  1383.     { address output.nonnull
  1384.       format.date "year" output.check
  1385.       new.sentence
  1386.       organization output
  1387.       publisher output
  1388.     }
  1389.       if$
  1390.     }
  1391.     { format.incoll.inproc.crossref output.nonnull
  1392.       format.pages output
  1393.     }
  1394.   if$
  1395.   new.block
  1396.   note output
  1397.   fin.entry
  1398. }
  1399. % The conference function is included for Scribe compatibility.
  1400. FUNCTION {conference} { inproceedings }
  1401. % A manual is technical documentation.
  1402. %    Required: title
  1403. %    Optional: author, organization, address, edition, month, year, note
  1404. FUNCTION {manual}
  1405. { output.bibitem
  1406.   author empty$
  1407.     { organization empty$
  1408.     'skip$
  1409.     { organization output.nonnull
  1410.       address output
  1411.     }
  1412.       if$
  1413.     }
  1414.     { format.authors output.nonnull }
  1415.   if$
  1416.   new.block
  1417.   format.btitle "title" output.check
  1418.   author empty$
  1419.     { organization empty$
  1420.     { address new.block.checka
  1421.       address output
  1422.     }
  1423.     'skip$
  1424.       if$
  1425.     }
  1426.     { organization address new.block.checkb
  1427.       organization output
  1428.       address output
  1429.     }
  1430.   if$
  1431.   format.edition output
  1432.   format.date output
  1433.   new.block
  1434.   note output
  1435.   fin.entry
  1436. }
  1437. % A mastersthesis is a Master's thesis.
  1438. %    Required: author, title, school, year
  1439. %    Optional: type, address, month, note
  1440. FUNCTION {mastersthesis}
  1441. { output.bibitem
  1442.   format.authors "author" output.check
  1443.   new.block
  1444.   format.title "title" output.check
  1445.   new.block
  1446.   "Master's thesis" format.thesis.type output.nonnull
  1447.   school "school" output.check
  1448.   address output
  1449.   format.date "year" output.check
  1450.   new.block
  1451.   note output
  1452.   fin.entry
  1453. }
  1454. % A misc is something that doesn't fit elsewhere.
  1455. %    Required: at least one of the `optional' fields
  1456. %    Optional: author, title, howpublished, month, year, note
  1457. FUNCTION {misc}
  1458. { output.bibitem
  1459.   format.authors output
  1460.   title howpublished new.block.checkb
  1461.   format.title output
  1462.   howpublished new.block.checka
  1463.   howpublished output
  1464.   format.date output
  1465.   new.block
  1466.   note output
  1467.   fin.entry
  1468.   empty.misc.check
  1469. }
  1470. % A phdthesis is like a mastersthesis.
  1471. %    Required: author, title, school, year
  1472. %    Optional: type, address, month, note
  1473. FUNCTION {phdthesis}
  1474. { output.bibitem
  1475.   format.authors "author" output.check
  1476.   new.block
  1477.   format.btitle "title" output.check
  1478.   new.block
  1479.   "PhD thesis" format.thesis.type output.nonnull
  1480.   school "school" output.check
  1481.   address output
  1482.   format.date "year" output.check
  1483.   new.block
  1484.   note output
  1485.   fin.entry
  1486. }
  1487. % A proceedings is a conference proceedings.
  1488. % If there is an organization but no editor field, the organization will
  1489. % appear as the first optional field (we try to make the first block nonempty);
  1490. % if there's no address field, the month (& year) will appear just before note.
  1491. %    Required: title, year
  1492. %    Optional: editor, volume or number, series, address, month,
  1493. %            organization, publisher, note
  1494. FUNCTION {proceedings}
  1495. { output.bibitem
  1496.   editor empty$
  1497.     { organization output }
  1498.     { format.editors output.nonnull }
  1499.   if$
  1500.   new.block
  1501.   format.btitle "title" output.check
  1502.   format.bvolume output
  1503.   format.number.series output
  1504.   address empty$
  1505.     { editor empty$
  1506.     { publisher new.sentence.checka }
  1507.     { organization publisher new.sentence.checkb
  1508.       organization output
  1509.     }
  1510.       if$
  1511.       publisher output
  1512.       format.date "year" output.check
  1513.     }
  1514.     { address output.nonnull
  1515.       format.date "year" output.check
  1516.       new.sentence
  1517.       editor empty$
  1518.     'skip$
  1519.     { organization output }
  1520.       if$
  1521.       publisher output
  1522.     }
  1523.   if$
  1524.   new.block
  1525.   note output
  1526.   fin.entry
  1527. }
  1528. % A techreport is a technical report.
  1529. %    Required: author, title, institution, year
  1530. %    Optional: type, number, address, month, note
  1531. FUNCTION {techreport}
  1532. { output.bibitem
  1533.   format.authors "author" output.check
  1534.   new.block
  1535.   format.title "title" output.check
  1536.   new.block
  1537.   format.tr.number output.nonnull
  1538.   institution "institution" output.check
  1539.   address output
  1540.   format.date "year" output.check
  1541.   new.block
  1542.   note output
  1543.   fin.entry
  1544. }
  1545. % An unpublished is something that hasn't been published.
  1546. %    Required: author, title, note
  1547. %    Optional: month, year
  1548. FUNCTION {unpublished}
  1549. { output.bibitem
  1550.   format.authors "author" output.check
  1551.   new.block
  1552.   format.title "title" output.check
  1553.   new.block
  1554.   note "note" output.check
  1555.   format.date output
  1556.   fin.entry
  1557. }
  1558. % We use entry type `misc' for an unknown type; BibTeX gives a warning.
  1559. FUNCTION {default.type} { misc }
  1560. % Here are macros for common things that may vary from style to style.
  1561. % Users are encouraged to use these macros.
  1562. %
  1563. % Months are either written out in full or abbreviated
  1564. MACRO {jan} {"Jan."}
  1565. MACRO {feb} {"Feb."}
  1566. MACRO {mar} {"Mar."}
  1567. MACRO {apr} {"Apr."}
  1568. MACRO {may} {"May"}
  1569. MACRO {jun} {"June"}
  1570. MACRO {jul} {"July"}
  1571. MACRO {aug} {"Aug."}
  1572. MACRO {sep} {"Sept."}
  1573. MACRO {oct} {"Oct."}
  1574. MACRO {nov} {"Nov."}
  1575. MACRO {dec} {"Dec."}
  1576. % Journals are either written out in full or abbreviated;
  1577. % the abbreviations are like those found in ACM publications.
  1578. %
  1579. % To get a completely different set of abbreviations, it may be best to make
  1580. % a separate .bib file with nothing but those abbreviations; users could then
  1581. % include that file name as the first argument to the \bibliography command
  1582. MACRO {acmcs} {"ACM Comput. Surv."}
  1583. MACRO {acta} {"Acta Inf."}
  1584. MACRO {cacm} {"Commun. ACM"}
  1585. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  1586. MACRO {ibmsj} {"IBM Syst.~J."}
  1587. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  1588. MACRO {ieeetc} {"IEEE Trans. Comput."}
  1589. MACRO {ieeetcad}
  1590.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  1591. MACRO {ipl} {"Inf. Process. Lett."}
  1592. MACRO {jacm} {"J.~ACM"}
  1593. MACRO {jcss} {"J.~Comput. Syst. Sci."}
  1594. MACRO {scp} {"Sci. Comput. Programming"}
  1595. MACRO {sicomp} {"SIAM J. Comput."}
  1596. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  1597. MACRO {tods} {"ACM Trans. Database Syst."}
  1598. MACRO {tog} {"ACM Trans. Gr."}
  1599. MACRO {toms} {"ACM Trans. Math. Softw."}
  1600. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  1601. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  1602. MACRO {tcs} {"Theoretical Comput. Sci."}
  1603. %% /usr/local/lib/tex/bibtex/phyjfull.btx, Tue Jun 30 08:37:48 1992
  1604. %% Edit by Nelson H. F. Beebe <beebe@alfred.math.utah.edu>
  1605. %% Change file names in leading comment
  1606. % Journal Title Abbreviations from the Physical Review Style and Notation
  1607. %    Guide, July, 1983, in BAPS Vol. 28.
  1608. %  Selected by Cris Barnes and Charles Karney, March 1988
  1609. % IMPORTANT!! Don't make changes to this file without making the
  1610. %           corresponding changes to
  1611. %            phyjabb.bib
  1612. %            phyjabb.btx
  1613. MACRO {advp} {"Advances in Physics"}
  1614. MACRO {ajp} {"American Journal of Physics"}
  1615. MACRO {ao} {"Applied Optics"}
  1616. MACRO {apl} {"Applied Physics Letters"}
  1617. MACRO {apj} {"Astrophysical Journal"}
  1618. MACRO {baps} {"Bulletin of the American Physical Society"}
  1619. MACRO {cpc} {"Computer Physics Communications"}
  1620. MACRO {cppcf} {"Comments on Plasma Physics and Controlled Fusion"}
  1621. MACRO {fed} {"Fusion Engineering and Design"}
  1622. MACRO {ft} {"Fusion Technology"}
  1623. MACRO {ieeens} {"IEEE Transactions on Nuclear Science"}
  1624. MACRO {ieeeps} {"IEEE Transactions on Plasma Science"}
  1625. MACRO {ijimw} {"International Journal of Infrared and Millimeter Waves"}
  1626. MACRO {ip} {"Infrared Physics"}
  1627. MACRO {jap} {"Journal of Applied Physics"}
  1628. MACRO {jcp} {"Journal of Computational Physics"}
  1629. MACRO {jetp} {"Soviet Physics-JETP"}
  1630. MACRO {jfe} {"Journal of Fusion Energy"}
  1631. MACRO {jfm} {"Journal of Fluid Mechanics"}
  1632. MACRO {jgr} {"Journal of Geophysical Research"}
  1633. MACRO {jmp} {"Journal of Mathematical Physics"}
  1634. MACRO {jne} {"Journal of Nuclear Energy"}
  1635. MACRO {jnec} {"Journal of Nuclear Energy, Part C: Plasma Physics, Accelerators, Thermonuclear Research"}
  1636. MACRO {jnm} {"Journal of Nuclear Materials"}
  1637. MACRO {josa} {"Journal of the Optical Society of America"}
  1638. MACRO {jpp} {"Journal of Plasma Physics"}
  1639. MACRO {jpsj} {"Journal of the Physical Society of Japan"}
  1640. MACRO {jvst} {"Journal of Vacuum Science and Technology"}
  1641. MACRO {nedf} {"Nuclear Engineering and Design/Fusion"}
  1642. MACRO {nf} {"Nuclear Fusion"}
  1643. MACRO {nim} {"Nuclear Instruments and Methods"}
  1644. MACRO {nimpr} {"Nuclear Instruments and Methods in Physics Research"}
  1645. MACRO {nt/f} {"Nuclear Technology/Fusion"}
  1646. MACRO {pf} {"Physics of Fluids"}
  1647. MACRO {pfa} {"Physics of Fluids A: Fluid Dynamics"}
  1648. MACRO {pfb} {"Physics of Fluids B: Plasma Physics"}
  1649. MACRO {pl} {"Physics Letters"}
  1650. MACRO {pla} {"Physics Letters A"}
  1651. MACRO {pnas} {"Proceedings of the National Academy of Sciences of the USA"}
  1652. MACRO {pp} {"Plasma Physics"}
  1653. MACRO {ppcf} {"Plasma Physics and Controlled Fusion"}
  1654. MACRO {prl} {"Physical Review Letters"}
  1655. MACRO {pr} {"Physical Review"}
  1656. MACRO {pra} {"Physical Review A: General Physics"}
  1657. MACRO {ps} {"Physica Scripta"}
  1658. MACRO {rmp} {"Reviews of Modern Physics"}
  1659. MACRO {rsi} {"Review of Scientific Instruments"}
  1660. MACRO {sjpp} {"Soviet Journal of Plasma Phys."}
  1661. MACRO {spd} {"Soviet Physics-Doklady"}
  1662. MACRO {sptp} {"Soviet Physics-Technical Physics"}
  1663. MACRO {spu} {"Soviet Physics-Uspeki"}
  1664. % Now we read in the .BIB entries.
  1665. READ
  1666. % The sortify function converts to lower case after purify$ing; it's
  1667. % used in sorting and in computing alphabetic labels after sorting
  1668. %
  1669. % The chop.word(w,len,s) function returns either s or, if the first len
  1670. % letters of s equals w (this comparison is done in the third line of the
  1671. % function's definition), it returns that part of s after w.
  1672. % This long comment applies only to alphabetic labels
  1673. %
  1674. % The format.lab.names function makes a short label by using the initials of
  1675. % the von and Last parts of the names (but if there are more than four names,
  1676. % (i.e., people) it truncates after three and adds a superscripted "+";
  1677. % it also adds such a "+" if the last of multiple authors is "others").
  1678. % If there is only one name, and its von and Last parts combined have just
  1679. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  1680. % we take the first three letters of the last name.  The boolean
  1681. % et.al.char.used tells whether we've used a superscripted "+", so that we
  1682. % know whether to include a LaTeX macro for it.
  1683. %
  1684. % format.lab.names(s) ==
  1685. %  BEGIN
  1686. %    numnames := num.names$(s)
  1687. %    if numnames > 1 then
  1688. %        if numnames > 4 then
  1689. %        namesleft := 3
  1690. %        else
  1691. %        namesleft := numnames
  1692. %        nameptr := 1
  1693. %        nameresult := ""
  1694. %        while namesleft > 0
  1695. %          do
  1696. %        if (name_ptr = numnames) and
  1697. %             format.name$(s, nameptr, "{ff }{vv }{ll}{ jj}") = "others"
  1698. %           then nameresult := nameresult * "{\etalchar{+}}"
  1699. %            et.al.char.used := true
  1700. %           else nameresult := nameresult *
  1701. %                format.name$(s, nameptr, "{v{}}{l{}}")
  1702. %        nameptr := nameptr + 1
  1703. %        namesleft := namesleft - 1
  1704. %          od
  1705. %        if numnames > 4 then
  1706. %        nameresult := nameresult * "{\etalchar{+}}"
  1707. %        et.al.char.used := true
  1708. %    else
  1709. %        t := format.name$(s, 1, "{v{}}{l{}}")
  1710. %        if text.length$(t) < 2 then    % there's just one name-token
  1711. %        nameresult := text.prefix$(format.name$(s,1,"{ll}"),3)
  1712. %        else
  1713. %        nameresult := t
  1714. %        fi
  1715. %    fi
  1716. %    return nameresult
  1717. %  END
  1718. %
  1719. % Exactly what fields we look at in constructing the primary part of the label
  1720. % depends on the entry type; this selectivity (as opposed to, say, always
  1721. % looking at author, then editor, then key) helps ensure that "ignored" fields,
  1722. % as described in the LaTeX book, really are ignored.  Note that MISC is part
  1723. % of the deepest `else' clause in the nested part of calc.label; thus, any
  1724. % unrecognized entry type in the database is handled correctly.
  1725. %
  1726. % There is one auxiliary function for each of the four different sequences of
  1727. % fields we use.  The first of these functions looks at the author field, and
  1728. % then, if necessary, the key field.  The other three functions, which might
  1729. % look at two fields and the key field, are similar, except that the key field
  1730. % takes precedence over the organization field (for labels---not for sorting).
  1731. %
  1732. % The calc.label function calculates the preliminary label of an entry, which
  1733. % is formed by taking three letters of information from the author or editor or
  1734. % key or organization field (depending on the entry type and on what's empty,
  1735. % but ignoring a leading "The " in the organization), and appending the last
  1736. % two characters (digits) of the year. It is an error if the appropriate fields
  1737. % among author, editor, organization, and key are missing, and we use
  1738. % the first three letters of the cite$ in desperation when this happens.
  1739. % The resulting label has the year part, but not the name part, purify$ed
  1740. % (purify$ing the year allows some sorting shenanigans by the user).
  1741. %
  1742. % This function also calculates the version of the label to be used in sorting.
  1743. %
  1744. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  1745. % otherwise identical labels, but we can't calculated those "extra.label"s
  1746. % until after sorting.
  1747. %
  1748. % calc.label ==
  1749. %  BEGIN
  1750. %    if type$ = "book" or "inbook" then
  1751. %        author.editor.key.label
  1752. %    else if type$ = "proceedings" then
  1753. %        editor.key.organization.label
  1754. %    else if type$ = "manual" then
  1755. %        author.key.organization.label
  1756. %    else
  1757. %        author.key.label
  1758. %    fi fi fi
  1759. %    label := label * substring$(purify$(field.or.null(year)), -1, 2)
  1760. %        % assuming we will also sort, we calculate a sort.label
  1761. %    sort.label := sortify(label), but use the last four, not two, digits
  1762. %  END
  1763. % When sorting, we compute the sortkey by executing "presort" on each entry.
  1764. % The presort key contains a number of "sortify"ed strings, concatenated
  1765. % with multiple blanks between them.  This makes things like "brinch  per"
  1766. % come before "brinch hansen  per".
  1767. %
  1768. % The fields used here are: the sort.label for alphabetic labels (as set by
  1769. % calc.label), followed by the author names (or editor names or organization
  1770. % (with a leading "The " removed) or key field, depending on entry type and on
  1771. % what's empty), followed by year, followed by the first bit of the title
  1772. % (chopping off a leading "The ", "A ", or "An ").
  1773. % Names are formatted: Von Last First Junior.
  1774. % The names within a part will be separated by a single blank
  1775. % (such as "brinch hansen"), two will separate the name parts themselves
  1776. % (except the von and last), three will separate the names,
  1777. % four will separate the names from year (and from label, if alphabetic),
  1778. % and four will separate year from title.
  1779. %
  1780. % The sort.format.names function takes an argument that should be in
  1781. % BibTeX name format, and returns a string containing "   "-separated
  1782. % names in the format described above.  The function is almost the same
  1783. % as format.names.
  1784. % This long comment applies only to alphabetic labels, when sorted
  1785. %
  1786. % Now comes the final computation for alphabetic labels, putting in the 'a's
  1787. % and 'b's and so forth if required.  This involves two passes: a forward
  1788. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  1789. % to put in the 'a's (we don't want to put in 'a's unless we know there
  1790. % are 'b's).
  1791. % We have to keep track of the longest (in width$ terms) label, for use
  1792. % by the "thebibliography" environment.
  1793. %
  1794. % VAR: longest.label, last.sort.label, next.extra: string
  1795. %      longest.label.width, last.extra.num: integer
  1796. %
  1797. % initialize.longest.label ==
  1798. %  BEGIN
  1799. %    longest.label := ""
  1800. %    last.sort.label := int.to.chr$(0)
  1801. %    next.extra := ""
  1802. %    longest.label.width := 0
  1803. %    last.extra.num := 0
  1804. %  END
  1805. %
  1806. % forward.pass ==
  1807. %  BEGIN
  1808. %    if last.sort.label = sort.label then
  1809. %        last.extra.num := last.extra.num + 1
  1810. %        extra.label := int.to.chr$(last.extra.num)
  1811. %    else
  1812. %        last.extra.num := chr.to.int$("a")
  1813. %        extra.label := ""
  1814. %        last.sort.label := sort.label
  1815. %    fi
  1816. %  END
  1817. %
  1818. % reverse.pass ==
  1819. %  BEGIN
  1820. %    if next.extra = "b" then
  1821. %        extra.label := "a"
  1822. %    fi
  1823. %    label := label * extra.label
  1824. %    if width$(label) > longest.label.width then
  1825. %        longest.label := label
  1826. %        longest.label.width := width$(label)
  1827. %    fi
  1828. %    next.extra := extra.label
  1829. %  END
  1830. % Now comes the computation for numeric labels.
  1831. % We use either the sorted order or original order.
  1832. % We still have to keep track of the longest (in width$ terms) label, for use
  1833. % by the "thebibliography" environment.
  1834. STRINGS { longest.label }
  1835. INTEGERS { number.label longest.label.width }
  1836. FUNCTION {initialize.longest.label}
  1837. { "" 'longest.label :=
  1838.   #1 'number.label :=
  1839.   #0 'longest.label.width :=
  1840. }
  1841. FUNCTION {longest.label.pass}
  1842. { number.label int.to.str$ 'label :=
  1843.   number.label #1 + 'number.label :=
  1844.   label width$ longest.label.width >
  1845.     { label 'longest.label :=
  1846.       label width$ 'longest.label.width :=
  1847.     }
  1848.     'skip$
  1849.   if$
  1850. }
  1851. EXECUTE {initialize.longest.label}
  1852. ITERATE {longest.label.pass}
  1853. % Now we're ready to start writing the .BBL file.
  1854. % We begin, if necessary, with a LaTeX macro for unnamed names in an alphabetic
  1855. % label; next comes stuff from the `preamble' command in the database files.
  1856. % Then we give an incantation containing the command
  1857. %     \begin{thebibliography}{...}
  1858. % where the `...' is the longest label.
  1859. %
  1860. % We also call init.state.consts, for use by the output routines.
  1861. FUNCTION {begin.bib}
  1862. { preamble$ empty$
  1863.     'skip$
  1864.     { preamble$ write$ newline$ }
  1865.   if$
  1866.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  1867. }
  1868. EXECUTE {begin.bib}
  1869. EXECUTE {init.state.consts}
  1870. % Now we produce the output for all the entries
  1871. ITERATE {call.type$}
  1872. % Finally, we finish up by writing the `\end{thebibliography}' command.
  1873. FUNCTION {end.bib}
  1874. { newline$
  1875.   "\end{thebibliography}" write$ newline$
  1876. }
  1877. EXECUTE {end.bib}
  1878.